package com.examplemartin.jpademo.pojo.po;

import com.examplemartin.jpademo.annotation.EntityCheck;
import com.examplemartin.jpademo.pojo.admin.BaseEntity;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ManyToMany;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 角色
 */

@Data
@EqualsAndHashCode(callSuper=true)
@Entity(name = "t_role")
public class RolePO extends BaseEntity implements Serializable {

  public final  static int ROLE_STATUS_ENABLE = 1;
  public final  static int ROLE_STATUS_DISABLE = -1;
  @EntityCheck(required = true,errRequired = "必须输入角色名")
  private String name;

  private String url;

  private String icon;

  // 角色对应的权限
  @ManyToMany(cascade = CascadeType.REFRESH)
  @Column(nullable = true)
  @JsonIgnore
  private List<MenuPO> authorities;

  // 角色状态
  @Column(nullable = true)
  private Integer status = ROLE_STATUS_ENABLE;

  @Column(nullable = true)
  private String comment;

  @Override
  public String toString() {
    return "RolePO{" +
        "name='" + name + '\'' +
        ", url='" + url + '\'' +
        ", icon='" + icon + '\'' +
        ", status=" + status +
        ", comment='" + comment + '\'' +
        '}';
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getUrl() {
    return url;
  }

  public void setUrl(String url) {
    this.url = url;
  }

  public String getIcon() {
    return icon;
  }

  public void setIcon(String icon) {
    this.icon = icon;
  }

  public Integer getStatus() {
    return status;
  }

  public void setStatus(Integer status) {
    this.status = status;
  }

  public String getComment() {
    return comment;
  }

  public void setComment(String comment) {
    this.comment = comment;
  }
}
